# 骨质测量页面
#
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QAction, QLineEdit, qApp, QDesktopWidget, QTabWidget, QPushButton,QDialog, QMessageBox
from PyQt5.QtGui import QIcon, QFont
from Bones.zhou import *
from Bones.yue import *
from Bones.sanjiao import *
from Bones.daduojiao import *
from Bones.xiaoduojiao import *
from Bones.tou import *
from Bones.gou import *

class Bones(QTabWidget):

    def __init__(self,jianchahao='',xingbie='0',nianling='0'):
        super().__init__()
        global name,gender,age
        name = jianchahao
        gender = xingbie
        age = nianling
        self.initUI()

    def initUI(self):

        exitAction = QAction(QIcon('exit24.png'), 'Exit', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.triggered.connect(qApp.quit)


        btn = QPushButton('返回', self)
        btn.setToolTip('<b>返回</b>')
        btn.setFont(QFont('SansSerif', 14))
        btn.resize(100, 60)
        btn.move(100, 420)
        btn.clicked.connect(self.on_back_clicked)

        btn_next = QPushButton('测算', self)
        btn_next.setToolTip('<b>测算</b>')
        btn_next.setFont(QFont('SansSerif', 14))
        btn_next.resize(100, 60)
        btn_next.move(700, 420)
        btn_next.clicked.connect(self.on_next_clicked)

        zhouBone_instance = zhouBone(name,gender)
        yueBone_instance  = yueBone(name,gender)
        sanjiaoBone_instance  = sanjiaoBone(name,gender)
        daduojiaoBone_instance  = daduojiaoBone(name,gender)
        xiaoduojiaoBone_instance  = xiaoduojiaoBone(name,gender)
        touBone_instance  = touBone(name,gender)
        gouBone_instance  = gouBone(name,gender)


        self.addTab(zhouBone_instance,QIcon(),'舟状骨')
        self.addTab(yueBone_instance,QIcon(),'月状骨')
        self.addTab(sanjiaoBone_instance,QIcon(),'三角骨')
        self.addTab(daduojiaoBone_instance,QIcon(),'大多角骨')
        self.addTab(xiaoduojiaoBone_instance,QIcon(),'小多角骨')
        self.addTab(touBone_instance,QIcon(),'头状骨')
        self.addTab(gouBone_instance,QIcon(),'钩状骨')
        self.tabBar().setStyleSheet("font-size:30px;")

        self.setFixedSize(900, 500)
        self.setWindowTitle('玉环县人民医院 TW3骨龄法 软件')
        self.setWindowIcon(QIcon("images/myicon.png"))
        self.center()
        self.show()


    def center(self):
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())

    # 点击返回按钮的时候 引入主界面并将自己销毁
    def on_back_clicked(self):
        from gender import Gender
        self.diag = Gender(name,age)
        self.diag.show()
        self.window().hide()

    def on_next_clicked(self):
        from result import Result
        self.diag = Result(name)
        self.diag.show()
        self.window().hide()

    def closeEvent(self, QCloseEvent):
        reply = QMessageBox.question(self, '退出？', "确定退出吗?",
                                     QMessageBox.Yes, QMessageBox.No)
        if reply == QMessageBox.Yes:
            QCloseEvent.accept()
            qApp.quit
        else:
            QCloseEvent.ignore()
if __name__ == '__main__':
    app = QApplication(sys.argv)
    st = Bones()
    sys.exit(app.exec_())
